#!/usr/bin/bash

PIP_PATH=/usr/local/pyenv/shims/pip
export TMPDIR=/tmp/pip-tmp

# setup large tmp for install
mkdir -p $TMPDIR
sudo mount -o remount,size=2G /tmp
sudo mount -o rw,remount /

# run command
sudo TMPDIR=$TMPDIR PIP_NO_CACHE_DIR=1 $PIP_PATH "$@"

# cleanup
sudo mount -o ro,remount /
rm -rf $TMPDIR
sudo mount -o remount /tmp
